Skip to content

fix(ai): report compacted model context - #312

Open
arhxam wants to merge 1 commit into
getopenscreen:mainfrom
arhxam:codex/accurate-compacted-context-budget
Open

fix(ai): report compacted model context#312
arhxam wants to merge 1 commit into
getopenscreen:mainfrom
arhxam:codex/accurate-compacted-context-budget

Conversation

@arhxam

@arhxam arhxam commented Aug 8, 2026

Copy link
Copy Markdown

Summary

  • feed the chat context pill from the existing native chatBudget endpoint, which measures the messages actually sent to the model
  • retain the renderer transcript estimate as an immediate/browser/error fallback
  • refresh usage whenever the active session's visible message array changes, including after manual compaction
  • ignore late budget responses from a previously selected session

This is a follow-up to #238: preserving the complete transcript was correct, but it meant the transcript-based meter no longer reflected the compacted model payload.

Related issue

Related to #238

Type of change

  • Bug fix
  • Feature
  • Enhancement
  • Documentation
  • Refactor / maintenance
  • Performance
  • Security

Release impact

  • Patch
  • Minor
  • Major / breaking change
  • No release note needed

Desktop impact

  • Windows
  • macOS
  • Linux
  • Installer / packaging
  • Not platform-specific

Screenshots / video

Not included; the context pill retains its existing UI and now receives the correct post-compaction value.

Testing

  • npx vitest --run src/components/ai-edition/useChatBudget.test.ts (3 passed)
    • renderer estimate before native usage arrives
    • stale response ignored after session switch
    • unchanged visible transcript refreshes from 500 to 40 model tokens after compaction
  • npm run test (1,680 passed, 1 skipped across 141 files)
  • npx tsc --noEmit
  • npx tsc -p tsconfig.test.json --noEmit
  • npx biome check on all four changed files
  • npm run docs:check
  • npm run i18n:check
  • npm run build-vite

Authored with Codex assistance and manually verified against the native modelMessages(session) budget path.

@arhxam
arhxam requested a review from EtienneLescot as a code owner August 8, 2026 18:35
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@arhxam, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 36 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c74ea515-940d-45fd-ac64-fda77814e38e

📥 Commits

Reviewing files that changed from the base of the PR and between 4e7a85b and e12bbab.

📒 Files selected for processing (4)
  • src/components/ai-edition/LeftPanel.tsx
  • src/components/ai-edition/chatBudget.ts
  • src/components/ai-edition/useChatBudget.test.ts
  • src/components/ai-edition/useChatBudget.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant